home *** CD-ROM | disk | FTP | other *** search
- Path: free1-slip207.tele.queensu.ca!user
- From: 3gl21@qlink.queensu.ca (Gregory Lo)
- Newsgroups: comp.lang.c++
- Subject: Re: Getting functions out of libraries to work
- Date: Wed, 21 Feb 1996 20:45:51 -0608
- Organization: Queen's University
- Message-ID: <3gl21-2102962045510001@free1-slip207.tele.queensu.ca>
- References: <312BBC29.6772@uni.massey.ac.nz>
- Reply-To: 3gl21@qlink.queensu.ca
- NNTP-Posting-Host: free1-slip207.tele.queensu.ca
- X-Newsreader: Yet Another NewsWatcher 2.2.0b4
-
- In article <312BBC29.6772@uni.massey.ac.nz>, Nigel.Ramsay.1@massey.ac.nz wrote:
-
- > I am trying to get some functions out of a library to work. The problem
- > is that I keep getting an "unresolved external" error whenever I try to
- > call the functions.
- > The funny thing is that it works fine when I compile under just C.
-
- The functions in the library were compiled in C, with "C" linkage.
-
- Your C++ compiler will mangle the names of all the identifiers. To
- prevent this, surround the prototypes of the C functions you're trying to
- access with 'extern "C" {' and '}'
-
- You could go into the header file and manually change add these lines, or
- you could use them before you #include the appropriate header file.
-
- Many companies that produce C libs or publish headers for C APIs, usually
- put these statements in the actual header file with #if statements that
- check for a C++ compiler. The resulting header file will work correctly
- when accessed from either a C compiler or from a C++ compiler.
- Greg Lo
-